#include <QStringListModel>

#include "insertdatadialog.h"

InsertDataDialog::InsertDataDialog( QWidget * parent) 
	: QDialog(parent)
{
	setupUi(this);
	
	subjectWidget = new InsertDataWidget("subjects");
	QVBoxLayout *subjectLayout = new QVBoxLayout;
	subjectLayout->addWidget( subjectWidget );
	subjectGBox->setLayout( subjectLayout );
	
	placeWidget = new InsertDataWidget("places");
	QVBoxLayout *placeLayout = new QVBoxLayout;
	placeLayout->addWidget( placeWidget );
	placeGBox->setLayout( placeLayout );
	
	teacherWidget = new InsertDataWidget("teachers");
	QVBoxLayout *teacherLayout = new QVBoxLayout;
	teacherLayout->addWidget( teacherWidget );
	teacherGBox->setLayout( teacherLayout );
	
	connect(okButton,SIGNAL(clicked()),this,SLOT(submit()));

}

void InsertDataDialog::connectModel()
{
	subjectWidget->connectModel();
	placeWidget->connectModel();
	teacherWidget->connectModel();
}

void InsertDataDialog::submit()
{
	subjectWidget->submit();
	placeWidget->submit();
	teacherWidget->submit();
	
	close();
}

void InsertDataDialog::on_cancelButton_clicked()
{
	subjectWidget->revert();
	placeWidget->revert();
	teacherWidget->revert();
	
	close();
}

void InsertDataDialog::refresh()
{
	subjectWidget->refresh();
	placeWidget->refresh();
	teacherWidget->refresh();
}
